

def testc():
    import socket

    # 创建套接字对象
    client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    # 获取本地主机名和端口号
    host = "127.0.0.1"
    port = 12476

    # 连接服务器
    client_socket.connect((host, port))
    client_socket.sendall(('测试').encode("utf-8"))
    # 接收消息并打印

    # 关闭连接
    while(1):
        message = client_socket.recv(102400)
        print(message.decode('utf-8'))
    client_socket.close()


if __name__=="__main__":
    print("a client has start")
    testc()